package com.smarth.zhizulian.utils.listhelper.impl.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.smarth.zhizulian.utils.listhelper.inter.IDataAdapter;

import java.util.List;

/**
 * Created by 18865 on 2018/2/8.
 */

public abstract class RListDataAdapter<T> extends BaseQuickAdapter<T, BaseViewHolder> implements IDataAdapter<List<T>> {
    public RListDataAdapter(int layoutResId, @Nullable List<T> data) {
        super(layoutResId, data);
    }

    public RListDataAdapter(@Nullable List<T> data) {
        super(data);
    }

    public RListDataAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    public void onGetData(List<T> ts, boolean isRefresh) {
        if (isRefresh) {
            setNewData(ts);
        } else {
            addData(ts);
        }
    }

    @Override
    public boolean isDataEmpty() {
        return getData() != null && getData().isEmpty();
    }

    @Override
    public List<T> getMyData() {
        return getData();
    }
}
